package cn.virens;

import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import cn.hutool.core.io.FileUtil;

public class Ttt {
	public static void main(String[] args) {
		String jsonText = FileUtil.readString("D:/test.json", Charset.forName("UTF-8"));

		JSONArray array = JSON.parseArray(jsonText);

		StringBuilder[] builder = new StringBuilder[50];
		for (int i = 0; i < builder.length; i++) {
			builder[i] = new StringBuilder();
		}

		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;

		for (Integer num : array.toJavaList(Integer.class)) {
			if (num > max) max = num;
			if (num < min) min = num;
		}

		int f = (int) Math.ceil((double) (max - min) / (builder.length));

		System.out.println(max);
		System.out.println(min);
		System.out.println(f);
		System.out.println(max - min);
		System.out.println(min + f * 0);
		System.out.println(min + f * builder.length);

		for (Integer num : array.toJavaList(Integer.class)) {
			for (int i = 0; i < builder.length; i++) {
				if ((num - min) / f == i) {
					builder[i].append("*");
				} else {
					builder[i].append(" ");
				}
			}
		}

		List<String> text = new ArrayList<>();
		for (int i = 0; i < builder.length; i++) {
			text.add(builder[i].toString());
		}

		File file = new File("D:/out.txt");
		FileUtil.writeLines(text, file, Charset.forName("UTF-8"));
	}
}
